//
//  RegDoctorDetialInfoViewController.m
//  安好
//
//  Created by lianchuang on 14-12-9.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "RegDoctorDetialInfoViewController.h"
#import "ConsultDocListCell.h"
#import "RegDoctorDetialCell.h"
#import "DocHospViewCell.h"
//
#import "ExpertViewCell.h"
//简介+擅长
#import "RegIntroductionGoodCell.h"
#import "DocCommentCell.h"
//医生modal
#import "RegDoctorDetialInfoModal.h"
//医院modal
#import "RegDocInfoHospitalModal.h"

#import "RegEncyViewController.h"

#import "PopoverView.h"
//用户评价
#import "EncyMyCommentViewController.h"
//可挂号的医生详情
#import "RegCanGuaHaoDoctorModal.h"
//可挂号的modal
#import "RegSchedulesModal.h"

#define iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)

@interface RegDoctorDetialInfoViewController ()<UITableViewDataSource,UITableViewDelegate,EncyMyCommentViewControllerDelegate>

@property (strong, nonatomic) UITableView *tableView;

@property(strong,nonatomic)NSMutableArray * hospitalArray;

@property(nonatomic,strong)RegDoctorDetialInfoModal * docInfoModal;

@property(nonatomic,strong)RegCanGuaHaoDoctorModal * docGuahaoModal;
/**
 *  tab的footerView
 */
@property(nonatomic,strong)UIView * footerView;

@property(nonatomic,copy)NSString * GuahaoDoctorId;
/**
 *  菊花加载标志: 0是没有网络请求结束;1是另一个网络请求结束，如果当自己的网络请求结束后置为1
 */
@property(nonatomic,assign)NSInteger uploadFlag;
/**
 *  获取到挂号网的doctorid的标志在，没有获取到是0，获取到是1，当下一个也也页面pop回到这个页面的时候，如果这个标志为1那么设为2.
 */
@property(nonatomic,assign)NSInteger guahaoFlag;
/**
 *  获取到医生数据的时候为1，没有获取到为0
 */
@property(nonatomic,assign)NSInteger docInfoFlag;
/**
 *  挂号的button
 */
@property(nonatomic,strong)UIButton * guahaoButton;
/**
 *  schedules
 */
@property(nonatomic,strong)NSMutableArray * schedulesArray;
@end

@implementation RegDoctorDetialInfoViewController
{
    NSArray *titles;
    NSArray *images;
    NSArray *selectArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.hospitalArray = [NSMutableArray arrayWithCapacity:0];
    self.schedulesArray =[NSMutableArray arrayWithCapacity:0];
    [self makeNavBar];
    [self makeTableView];
    self.tableView.hidden = YES;
    [self showActionView];
    self.uploadFlag = 0;
    [self AFNetRequestForGuahaoDoctorChuzhengbiao];
    [self AFNetRequestForDoctorDetialInfo];

    titles = @[@"收藏", @"分享"];
    images = @[@"百科_收藏", @"百科_分享"];
    selectArray=@[@"百科_收藏成功", @"百科_分享成功"];

}

-(void)loadRequestForUploadCommentCount
{
    [self showActionView];
    self.uploadFlag = 0;
    self.docInfoFlag = 0;
    if (self.guahaoFlag==1) {
        self.guahaoFlag = 2;
    }
    [self AFNetRequestForDoctorDetialInfo];
    
}
#pragma mark - 导航条设置
-(void)makeNavBar
{
    self.navigationItem.title = @"医生详情";
    
    //左按钮--返回
    UIBarButtonItem *backBtnImg = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"公用_返回.png"] style:UIBarButtonItemStylePlain target:self action:@selector(backClicked)];
    [backBtnImg setTintColor:[UIColor whiteColor]];
    self.navigationItem.leftBarButtonItem = backBtnImg;
    //右按钮-- “挂号记录”
    UIButton *rightButtonMore = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButtonMore.frame = CGRectMake(0,0, 23, 23);
    [rightButtonMore setImage:[UIImage imageNamed:@"公用_更多@2x.png"] forState:UIControlStateNormal];
    [rightButtonMore addTarget:self action:@selector(showListView:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:rightButtonMore];
}
-(void)backClicked{
    [self.navigationController popViewControllerAnimated:YES];
}
//筛选
-(void)showListView:(UIButton *)sender
{
    CGPoint point = CGPointMake(sender.frame.origin.x + sender.frame.size.width/2, 64);
    //    NSArray *titles = @[@"收藏", @"分享"];
    PopoverView *pop = [[PopoverView alloc] initWithPoint:point titles:titles images:images selectImage:selectArray];
    pop.selectRowAtIndex = ^(NSInteger index){
        switch (index) {
            case 0:
            {
                if ([[titles objectAtIndex:0] isEqualToString:@"收藏"]) {
                    [self collection];
                }
                else
                {
                    [self deleteCollection];
                }
            }
                break;
            case 1:
            {
                [self showShareView];
            }
                break;
                
            default:
                break;
        }
    };
    [pop show];
}
- (void)Login
{
    [self showActionView];
    NSString *postURL=[NSString stringWithFormat:@"%@collection/addCollection",kBaseURL];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *dict=@{
                         @"platform":kPlatform,
                         @"version":kVersion,
                         @"title":self.navigationItem.title,
                         @"objectid":self.doctorid,
                         @"type":@"4",
                         };
    [manager POST:postURL parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [self hiddenActionView];
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        if ([statusString isEqualToString:@"0"]) {
        }
        else{
            [self showCustomHudSingleLine:@"收藏成功"];
            titles = @[@"已收藏", @"分享"];
            images = @[@"百科_收藏成功", @"百科_分享"];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [self hiddenActionView];
    }];

}
- (void)collection
{
    [self isLogin];
}
- (void)deleteCollection
{
    [self showActionView];
    NSString *postURL=[NSString stringWithFormat:@"%@collection/delete/",kBaseURL];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *dict=@{
                         @"platform":kPlatform,
                         @"version":kVersion,
                         @"objectid":self.doctorid,
                         @"type":@"4",
                         };
    [manager POST:postURL parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        [self hiddenActionView];
        if ([statusString isEqualToString:@"0"]) {
        }
        else{
            [self showCustomHudSingleLine:@"取消收藏"];
            titles = @[@"收藏", @"分享"];
            images = @[@"百科_收藏", @"百科_分享"];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [self hiddenActionView];
    }];
}

//普通医生的详情
-(void)AFNetRequestForDoctorDetialInfo
{
    NSString *postURL = [NSString stringWithFormat:@"%@doctor/detailInfo",kBaseURL];
    NSDictionary * pararDic = @{@"platform":kPlatform,@"version":kVersion,@"doctorid":self.doctorid};
    //网络请求管理者
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager POST:postURL parameters:pararDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        MyNSLog("成功");
        if (self.uploadFlag == 1) {
            [self hiddenActionView];
        }else{
            self.uploadFlag = 1;
        }
        
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        if ([statusString isEqualToString:@"0"]){
            MyNSLog("%@",responseObject[@"msg"]);
        }else
        {
            NSDictionary * docInfoDic = responseObject[@"data"];
            NSString *iscollection=[NSString stringWithFormat:@"%@",[[responseObject valueForKey:@"data"] valueForKey:@"iscollection"]];
            
            if ([iscollection isEqualToString:@"0"]) {
                titles = @[@"收藏", @"分享"];
                images = @[@"百科_收藏", @"百科_分享"];
            }else
            {
                titles = @[@"已收藏", @"分享"];
                images = @[@"百科_收藏成功", @"百科_分享"];
            }
            NSArray * arr = @[docInfoDic];
            for (NSDictionary * dic in arr) {
                RegDoctorDetialInfoModal * modal = [[RegDoctorDetialInfoModal alloc] initWithDic:dic];
                self.docInfoModal = modal;
            }
            [self.hospitalArray removeAllObjects];
            for (NSDictionary * dic in self.docInfoModal.hospital) {
                RegDocInfoHospitalModal * hospital = [[RegDocInfoHospitalModal alloc] initWithDic:dic];
                [self.hospitalArray addObject:hospital];
            }
            
            self.docInfoFlag = 1;
            [self makeRegistrationAndColloectionButtonWithOffsetX:0 AndFlag:0];

           
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (self.uploadFlag == 1) {
            [self hiddenActionView];
        }else
        {
            self.uploadFlag = 1;
        }
        MyNSLog("网络请求失败");
    }];

}
/**
 *  获取挂号网医生出征信息id
 */
-(void)AFNetRequestForGuahaoDoctorChuzhengbiao
{
    NSString *postURL = [NSString stringWithFormat:@"%@guahao/doctordetail/",kBaseURL];
    NSDictionary * pararDic = @{@"platform":kPlatform,@"version":kVersion,@"doctorid":self.doctorid};
    //网络请求管理者
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager POST:postURL parameters:pararDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        MyNSLog("成功");
        if (self.uploadFlag == 1) {
            [self hiddenActionView];
        }else{
            self.uploadFlag = 1;
        }
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        if ([statusString isEqualToString:@"0"]){
            MyNSLog("%@",responseObject[@"msg"]);
            
        }else
        {
            RegCanGuaHaoDoctorModal * modal = [[RegCanGuaHaoDoctorModal alloc] initWithDic:responseObject[@"data"]];
            self.docGuahaoModal = modal;
            
            for (NSDictionary * dic in modal.schedules) {
                RegSchedulesModal * schModal = [[RegSchedulesModal alloc] initWithDic:dic];
                [self.schedulesArray addObject:schModal];
            }
            self.GuahaoDoctorId = modal.doctorId;
            MyNSLog("%@",responseObject[@"data"] );
           //医生挂号id
            self.GuahaoDoctorId = [responseObject[@"data"] objectForKey:@"doctorId"];
            if (self.GuahaoDoctorId == nil || [self.GuahaoDoctorId isEqualToString:@""]) {
                
            }else{
                self.guahaoFlag = 1;
                //创建挂号
                [self makeRegistrationAndColloectionButtonWithOffsetX:0 AndFlag:1];
            }
            
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (self.uploadFlag == 1) {
            [self hiddenActionView];
        }else
        {
            self.uploadFlag = 1;
        }
        MyNSLog("挂号网网络请求失败");
    }];
    


}

#pragma mark - 创建tableView 设置代理添加头视图
-(void)makeTableView
{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-iOS7TopMargin) style:UITableViewStyleGrouped];
    [self.view addSubview:self.tableView];
    self.tableView.backgroundColor = [ClassMethodsViewController colorWithHexString:BACK_BACKGROUNDCOLOR_16];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    //隐藏横向和竖向的滑条
    self.tableView.showsHorizontalScrollIndicator = NO;
    self.tableView.showsVerticalScrollIndicator = NO;
//    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView setSeparatorColor:[UIColor colorWithRed:221/255.0 green:221/255.0 blue:221/255.0 alpha:1.0]];
    self.footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 64)];
    if (iPhone6Plus) {
        self.footerView.height = 90;
    }
    self.footerView.backgroundColor = [ClassMethodsViewController colorWithHexString:BACK_BACKGROUNDCOLOR_16];
    self.tableView.tableFooterView = self.footerView;
    
}


-(void)makeRegistrationAndColloectionButtonWithOffsetX:(CGFloat)offsetY AndFlag:(NSInteger)flag
{
    
    if (self.docInfoFlag == 1 && self.uploadFlag == 1) {
        self.tableView.hidden = NO;
        [self.tableView reloadData];
        if (self.guahaoFlag == 1 || self.guahaoFlag == 2) {
            [self hiddenActionView];
        }
    }
    
    [self.guahaoButton removeFromSuperview];
    self.guahaoButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    self.guahaoButton.frame = CGRectMake(15, 10+offsetY, kScreenWidth-30,44);
    self.guahaoButton.titleLabel.font = [UIFont systemFontOfSize:15];
    if (iPhone6Plus) {
        self.guahaoButton.frame = CGRectMake(20, 15+offsetY, kScreenWidth-40,53);
        self.guahaoButton.titleLabel.font = [UIFont systemFontOfSize:17];
    }
    [self.footerView addSubview:self.guahaoButton];
    
    if (self.guahaoFlag == 1 || self.guahaoFlag == 2) {
        
        self.guahaoButton.backgroundColor = [UIColor colorWithRed:61/255.0 green:179/255.0 blue:230/255.0 alpha:1];
        [self.guahaoButton addTarget:self action:@selector(registrationButtonClicked) forControlEvents:UIControlEventTouchUpInside];
        if (self.guahaoFlag == 2) {
            self.guahaoFlag = 1;
        }
    }else
    {
        [self hiddenActionView];
        self.guahaoButton.backgroundColor = [UIColor colorWithRed:169/255.0 green:169/255.0 blue:169/255.0 alpha:1];
    }
    
    [self.guahaoButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [self.guahaoButton setTitle:@"挂号" forState:UIControlStateNormal];
    
    
}
-(void)registrationButtonClicked
{
    RegEncyViewController * reg = [[RegEncyViewController alloc] init];
    reg.doctorid = self.GuahaoDoctorId;
    [self.navigationController pushViewController:reg animated:YES];

}

#pragma mark UITableViewDatasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
        if (section == 0) {
            return 1;
        }else if (section == 1){
            //医院个数
            return self.hospitalArray.count;
        }else if(section == 2)
        {
            //擅长+简介
            return 2;
        }else
        {
            //用户评价
            return 1;
        }
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
        if (indexPath.section == 0) {
            if (iPhone6Plus) {
                return 155;
            }else{
                return 130;
            }
        }else if (indexPath.section == 2){
            if (indexPath.row == 1)// 简介
            {
                RegIntroductionGoodCell *cell=(RegIntroductionGoodCell *)[self tableView:self.tableView cellForRowAtIndexPath:indexPath];
                return cell.detialLable.bottom+13;
              
            }else
            {
                if (iPhone6Plus) {
                    return 53;
                }else{
                    return 44;
                }
            }
        }
        else
        {
            if (iPhone6Plus) {
                return 53;
            }else{
                return 44;
            }
        }
    
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section != 0) {
        if (iPhone6Plus) {
            return 12;
        }else{
            return 10;
        }
    }else
    {
        return 0.01;
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CGFloat flagWeight = 15.0;
    //医生详情
    if (indexPath.section == 0) {
        static NSString *Indentifier=@"DocDetial";
        RegDoctorDetialCell *cell=[tableView dequeueReusableCellWithIdentifier:Indentifier];
        if (!cell) {
            if (iPhone6Plus) {
                cell=[[[NSBundle mainBundle]loadNibNamed:@"RegDoctorDetialCell" owner:self options:nil] lastObject];
                flagWeight = 20;
            }else{
                cell=[[[NSBundle mainBundle]loadNibNamed:@"RegDoctorDetialCell" owner:self options:nil] firstObject];
            }
        }
        //安好认证--doctoruid不为0的时候显示
        if ([self.docInfoModal.doctoruid intValue] !=0) {
            cell.anhaoIdentLable.hidden = NO;
            cell.anhaoIdentLable.text = @"安好认证";
            cell.anhaoIdentLable.backgroundColor = [UIColor greenColor];
            cell.anhaoIdentLable.right = kScreenWidth - flagWeight;
            cell.anhaoIdentLable.top = cell.docImage.top;
        }else{
            cell.anhaoIdentLable.hidden = YES;
            cell.anhaoIdentLable.width = 1;
        }
        
        //医生头像
        cell.docImage.clipsToBounds = YES;
        cell.docImage.layer.cornerRadius = 3;
        [cell.docImage setImageWithURL:[NSURL URLWithString:self.docInfoModal.photourl] placeholderImage:[UIImage imageNamed:@"医生默认.png"]];
        
        //医生名字
        cell.docName.text = self.docInfoModal.doctorname;
        cell.docName.left = cell.docImage.right+15;
        cell.docName.width = kScreenWidth - flagWeight - cell.docName.left - cell.anhaoIdentLable.width;
        //科室
        cell.docHospital.text = [NSString stringWithFormat:@"科室:%@",self.docInfoModal.departmentname];
        cell.docHospital.left =cell.docName.left;
        cell.docHospital.width = kScreenWidth - flagWeight -cell.docHospital.left;
        //职称
        cell.docExpert.text = [NSString stringWithFormat:@"职称:%@",self.docInfoModal.doclevelname];
        cell.docExpert.left =cell.docName.left;
        cell.docExpert.width =kScreenWidth - flagWeight -cell.docExpert.left;
        //中间的横线
        cell.middleLineView.backgroundColor = [UIColor colorWithRed:221/255.0 green:221/255.0 blue:221/255.0 alpha:1];
        cell.middleLineView.left = flagWeight;
        cell.middleLineView.width = kScreenWidth - 2*flagWeight;
        cell.middleLineView.height = 0.3;
        cell.middleLineView.top = cell.height - 44;
        cell.zanBackView.left = flagWeight;
        cell.zanBackView.bottom = cell.height - (44-cell.zanBackView.height)/2.0;
        if (iPhone6Plus) {
            cell.middleLineView.top = cell.height - 53;
            cell.zanBackView.bottom = cell.height - (53-cell.zanBackView.height)/2.0;
        }
        cell.renZhenBackView.top = cell.zanBackView.top;
        cell.fansBackView.top = cell.zanBackView.top;
        cell.renZhenBackView.left = (kScreenWidth - cell.renZhenBackView.width)/2.0;
        cell.fansBackView.right = kScreenWidth - 16;
        
        cell.renZhenLable.text = [NSString stringWithFormat:@"同行认证(%@)",self.docInfoModal.agree];
        cell.docGood.text =[NSString stringWithFormat:@"赞(%@)",self.docInfoModal.good];
        cell.docFans.text = [NSString stringWithFormat:@"粉丝(%@)", self.docInfoModal.follower];
        
        
        return cell;
        
        }
    //医院个数
    else if (indexPath.section == 1){
            static NSString *Indentifier=@"hosp";
            DocHospViewCell *cell=[tableView dequeueReusableCellWithIdentifier:Indentifier];
            if (!cell) {
                if (iPhone6Plus) {
                    cell=[[[NSBundle mainBundle]loadNibNamed:@"DocHospViewCell" owner:self options:nil] objectAtIndex:1];
                }else{
                    cell=[[[NSBundle mainBundle]loadNibNamed:@"DocHospViewCell" owner:self options:nil] firstObject];
                }
            }
            RegDocInfoHospitalModal * hospitalModal = self.hospitalArray[indexPath.row];
            cell.docHosptal.text = hospitalModal.hospitalname;
            cell.hospLevel.text = hospitalModal.hospitallevel;
            
            return cell;
            
        }
    //擅长+简介
    else if (indexPath.section==2){
        
        RegIntroductionGoodCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RegGoodID"];
        if (cell == nil) {
            if (iPhone6Plus) {
                cell = [[[NSBundle mainBundle] loadNibNamed:@"RegIntroductionGoodCell" owner:self options:nil] lastObject];
            }else{
                cell = [[[NSBundle mainBundle] loadNibNamed:@"RegIntroductionGoodCell" owner:self options:nil] firstObject];
            }
        }
        
        if (indexPath.row == 0) {
            cell.goodLable.text = @"擅长";
            cell.detialLable.numberOfLines = 1;
            cell.detialLable.text = self.docInfoModal.feature;
            cell.detialLable.frame = CGRectMake(cell.goodLable.right+10, cell.goodLable.top, kScreenWidth-15-cell.detialLable.left, cell.goodLable.height);
            if (iPhone6Plus) {
                cell.detialLable.width =kScreenWidth-20-cell.detialLable.left;
            }
            
        }
        else{
            cell.goodLable.text = @"简介";
            cell.detialLable.numberOfLines = 0;
            cell.detialLable.text = self.docInfoModal.introduction;
            cell.detialLable.left = cell.goodLable.right+10;
            cell.detialLable.width = kScreenWidth -15-cell.detialLable.left;
            if (iPhone6Plus) {
                cell.detialLable.width = kScreenWidth -20-cell.detialLable.left;
            }
            cell.detialLable.top = cell.goodLable.top;
            
            if (cell.detialLable.text.length>0) {
                NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:cell.detialLable.text];
                NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
                [paragraphStyle setLineSpacing:5];//调整行间距
                [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [cell.detialLable.text length])];
                paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;
                cell.detialLable.attributedText = attributedString;
                [cell.detialLable sizeToFit];
            }
            
        }
        
        return cell;
        }
    //用户评价
    else{
            static NSString *Indentifier=@"comment";
            DocCommentCell *cell=[tableView dequeueReusableCellWithIdentifier:Indentifier];
            if (!cell) {
                if (iPhone6Plus) {
                    cell=[[[NSBundle mainBundle]loadNibNamed:@"DocCommentCell" owner:self options:nil] lastObject];
                }else{
                    cell=[[[NSBundle mainBundle]loadNibNamed:@"DocCommentCell" owner:self options:nil] firstObject];
                }
            }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.itemTitle.text = @"用户评价";
            cell.itemCount.text = [NSString stringWithFormat:@"%d",[self.docInfoModal.commencount intValue]];
            
            UIImage * jumpImg = [UIImage imageNamed:@"公用_跳转.png"];
            [cell.arrows setImage:jumpImg];
            cell.arrows.frame = CGRectMake(kScreenWidth-(15+jumpImg.size.width), (cell.contentView.height-jumpImg.size.height)/2.0, jumpImg.size.width,jumpImg.size.height);
            cell.itemCount.right = cell.arrows.left-5;
            return cell;
        
       
        }
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  
    //点击用户评价
    if (indexPath.section == 3 ) {
        EncyMyCommentViewController * doccomment  = [[EncyMyCommentViewController alloc] init];
        doccomment.commentKey = @"doctorid";
        doccomment.commentId = self.doctorid;
        doccomment.type = @"3";
        doccomment.delegate = self;
        [self.navigationController pushViewController:doccomment animated:YES];
    }

}

#pragma 实现share方法，通过点击的视图的tag值判断是什么类型的分享
- (void)share:(UITapGestureRecognizer *)shareTap{
    NSString * url= [NSString stringWithFormat:@"http://m.niruoanhao.com/share/doctor/%@",self.doctorid];
    NSString * title = @"安好，精确查找全国近四十万执业医生信息，快捷挂号";
    NSString * text = @"找对医生看对病，提供全国近四十万执业医生简介、擅长专业";
    UIImage * image = [UIImage imageNamed:@"二维码"];
    switch (shareTap.view.tag) {
        case 11:{//微信
            [self weixinShare:url :title :text :image];
        }
            break;
        case 12:{//朋友圈
            [self weixinFriendShare:url :title :text :image];
        }
            break;
        case 13:{//短信
            [self showSMSPicker:url :title :text :nil];
        }
            break;
        case 14:{//QQ
            [self qqShare:url :title :text :image];
        }
            break;
        case 15:{//QQ空间
            [self qqZoneShare:url :title :text :image];
        }
            break;
        case 16:{//新浪微博
            [self sinaWeiboShare:url :title :text :image];
        }
            break;
            
        default:
            break;
    }
}

@end




